<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" +request.getServerPort() + path + "/";
%>
<jsp:include page="head.jsp"></jsp:include>
<link type="text/css" rel="stylesheet" href="../laypage/skin/laypage.css" />
<script type="text/javascript" src="../laypage/laypage.js"></script> 

	<div class="main">
		<h2>分类管理</h2>
		<div class="manage">
			<table class="list">
				 <thead>
				<tr>
					<th>商品大类</th>
					<th>分类小类</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody id="everyNews">
			</tbody>

			</table>
		</div>
	</div>
	<div class="clear"></div>
    <div class="pager">
       <span id="layer" style="float:right"></span>
  </div>
</div>
<div id="footer">
	Copyright &copy; 2017云和学院 All Rights Reserved. 京ICP证1000001号</div>
</body>
</html>
<script type="text/javascript">
	/* 页面加载时调用NewsManageServlet 直接查询新闻列表 */
	$(document).ready(function() {
		resultData(1);
	});
	var resultData = function(curr) {	
		$("#everyNews").html("");
		$.ajax({
			url : "../CommodityClassifyAjax?pageIndex="+curr,
			type : "post",
			dataType : "json",
			success : function(data) {
				
				console.log(data.commentList.length);
				for (var i = 0; i < data.commentList.length; i++) {
					
					if(data.commentList[i].small_name!=""){
						$("#everyNews").append(
						   "<tr><td class='first w4 c'></td><td>"
						   +data.commentList[i].small_name
						   +"</td><td class='w1 c'><a href='../CommodityClassify_Servlet?small_id="
						   +data.commentList[i].small_id
						   +"&small_name="
						   +data.commentList[i].small_name
						   +"&big_id="
						   +data.commentList[i].big_id
						   +"&big_name="
						   +data.commentList[i].big_name
						   +"&manage=showall'>修改</a><a class='manageDel' href='../AddChangeDeleteClassify_Servlet?id="
						   +data.commentList[i].small_id
						   +"&manage=deletesmall'>删除</a></td></tr>"
						);
					}else{
						$("#everyNews").append(
								"<tr><td class='first w4 c'>"
								+data.commentList[i].big_name
								+"</td><td></td><td class='w1 c'><a href='../CommodityClassify_Servlet?big_id="
								+data.commentList[i].big_id
								+"&big_name="
								+data.commentList[i].big_name
								+"&manage=showall'>修改</a> <a class='manageDel' href='../AddChangeDeleteClassify_Servlet?id="
								+data.commentList[i].big_id
								+"&manage=deletebig'>删除</a></td></tr>"	
						);
					}
					
				}
				
				laypage({
					cont : "layer",
					skin: '#fb771f',
					pages : data.totalPage,
					curr : curr || 1,
					jump : function(obj, first) {
						if (!first) {
							resultData(obj.curr);
						}
					}
				});	
		}
		
		});
		
			}
</script>